package com.inspector.app.ui.login

import android.annotation.SuppressLint
import android.os.Bundle
import androidx.activity.viewModels
import com.example.commen.resource.CommentContect
import com.google.android.material.tabs.TabLayoutMediator
import com.inspector.app.databinding.DialogLoginBinding
import com.inspector.app.ui.base.BaseDJActivity
import com.inspector.app.util.ConstantUtil
import com.inspector.app.util.SharedPreferencesUtils
import java.text.SimpleDateFormat
import java.util.Date

class LoginActivity : BaseDJActivity() {

    private lateinit var bind: DialogLoginBinding
    private lateinit var tabAdapter: LoginTabAdapter
    private val viewModel: LoginModel by viewModels()
    override fun onCreate(savedInstanceState: Bundle?) {
        super.onCreate(savedInstanceState)
        bind = DialogLoginBinding.inflate(layoutInflater)
        setContentView(bind.root)
        viewModel.loginOut()
        initView()
    }


    private val titles = arrayOf("账号登录","短信登录" )
    @SuppressLint("SimpleDateFormat")
    private fun initView() {
       var  simpleDateFormat =SimpleDateFormat("yyyy年MM月dd日 HH:mm:ss");//
        //获取当前时间
        val date = Date(System.currentTimeMillis())
        val generationdate: String = simpleDateFormat.format(date)
        if (SharedPreferencesUtils.getString(ConstantUtil.INSTALLDATE)==null) {
            SharedPreferencesUtils.put(ConstantUtil.INSTALLDATE,generationdate)
        }
        tabAdapter = LoginTabAdapter(activity = this)
        bind.viewPager.adapter = tabAdapter
        TabLayoutMediator(bind.tabLayout, bind.viewPager) { tab, position ->
            tab.text = titles[position]
        }.attach()
    }

}